/*     */ package hmc;
/*     */ 
/*     */ import java.awt.Color;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Image;
/*     */ import java.awt.Toolkit;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.WindowEvent;
/*     */ import java.awt.event.WindowListener;
/*     */ import java.beans.PropertyVetoException;
/*     */ import java.io.BufferedReader;
/*     */ import java.io.BufferedWriter;
/*     */ import java.io.File;
/*     */ import java.io.FileReader;
/*     */ import java.io.FileWriter;
/*     */ import java.util.Set;
/*     */ import java.util.TreeMap;
/*     */ import javax.swing.DesktopManager;
/*     */ import javax.swing.ImageIcon;
/*     */ import javax.swing.JDesktopPane;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JInternalFrame;
/*     */ import javax.swing.JMenu;
/*     */ import javax.swing.JMenuBar;
/*     */ import javax.swing.JMenuItem;
/*     */ import javax.swing.SwingUtilities;
/*     */ import javax.swing.UIManager;
/*     */ 
/*     */ public class TopLevelGUI extends JFrame
/*     */   implements ActionListener, WindowListener
/*     */ {
/* 809 */   public static TreeMap ActiveConnectionDirectory = new TreeMap();
/* 810 */   public static TreeMap ConnectionDirectory = new TreeMap();
/*     */   JDesktopPane desktop;
/*     */   TestSuiteGUI TSGUI;
/*     */   OptionsGUI OGUI;
/*     */   Communicator[] comm;
/*     */   SerialPortCommunicator SC;
/*     */   PortSelect[] portSel;
/*     */   int commWinNum;
/*     */   int totalWinNum;
/*     */   int psCounter;
/*     */   public String Version;
/*     */   public String colorScheme;
/*     */   ImageIcon titleBarIcon;
/* 823 */   private final String DEFAULTDESKTOPBACKGROUNDIMAGE = "Images/BackgroundDefault.png";
/* 824 */   private final String COLDDESKTOPBACKGROUNDIMAGE = "Images/BackgroundCold.jpg";
/* 825 */   private final String WARMDESKTOPBACKGROUNDIMAGE = "Images/BackgroundWarm.jpg";
/*     */   private String desktopBackgroundImage;
/* 827 */   private final Color BLUEMENUBACKGROUND = new Color(2565974);
/* 828 */   private final Color GREENMENUBACKGROUND = new Color(2577959);
/* 829 */   private final Color REDMENUBACKGROUND = new Color(5646119);
/* 830 */   private final Color TEXTWHITE = new Color(16777215);
/* 831 */   private final Color TEXTBLACK = new Color(0);
/* 832 */   private final Color TEXTBLUE = new Color(6645181);
/* 833 */   private final Color TEXTGREEN = new Color(6667621);
/* 834 */   private final Color TEXTRED = new Color(12412261);
/* 835 */   private final Color REDWINDOWBACKGROUND = new Color(9125695);
/* 836 */   private final Color GREENWINDOWBACKGROUND = new Color(4160319);
/* 837 */   private final Color BLUEWINDOWBACKGROUND = new Color(4145035);
/* 838 */   private final Color REDBUTTONBACKGROUND = new Color(16177111);
/* 839 */   private final Color GREENBUTTONBACKGROUND = new Color(14153431);
/* 840 */   private final Color BLUEBUTTONBACKGROUND = new Color(14145526);
/* 841 */   private final Color REDSELECTIONBACKGROUND = new Color(6698807);
/* 842 */   private final Color GREENSELECTIONBACKGROUND = new Color(3630647);
/* 843 */   private final Color BLUESELECTIONBACKGROUND = new Color(3618662);
/*     */   private boolean SystemLAF;
/*     */   public static Color buttonBackground;
/*     */   public static Color windowBackground;
/*     */   public static Color menuBackground;
/*     */   public static Color selectionBackground;
/*     */   public static Color buttonText;
/*     */   public static Color windowText;
/*     */   public static Color menuText;
/*     */   private JMenuBar menuBar;
/*     */   private JMenu FileMenu;
/*     */   private JMenuItem ConnectionDirectoryMenuItem;
/*     */   private JMenuItem NewScriptMenuItem;
/*     */   private JMenuItem OpenEditorMenuItem;
/*     */   private JMenuItem TileFramesMenuItem;
/*     */   private JMenuItem ExitMenuItem;
/*     */   private JMenu ConnectionsMenu;
/*     */   private JMenuItem NewSerialConnectionMenuItem;
/*     */   private JMenuItem NewSSHConnectionMenuItem;
/*     */   private JMenu RunMenu;
/*     */   private JMenuItem RunTestSuiteMenuItem;
/*     */   private JMenu OptionsMenu;
/*     */   private JMenuItem WindowConfigurationMenuItem;
/*     */   private JMenu HelpMenu;
/*     */   private JMenuItem HelpMenuItem;
/*     */   private JMenuItem AboutMenuItem;
/*     */ 
/*     */   public TopLevelGUI()
/*     */   {
/*  28 */     super("Hazell");
/*  29 */     this.TSGUI = null;
/*  30 */     this.OGUI = null;
/*  31 */     this.comm = new Communicator[99];
/*  32 */     this.portSel = new PortSelect[2];
/*  33 */     this.commWinNum = 0;
/*  34 */     this.totalWinNum = 0;
/*  35 */     this.psCounter = 0;
/*  36 */     this.Version = "1.0";
/*  37 */     this.colorScheme = "default";
/*  38 */     this.titleBarIcon = new ImageIcon("Images/HMC_Icon.png");
/*  39 */     this.SystemLAF = true;
/*     */     try
/*     */     {
/*  45 */       UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
/*     */ 
/*  47 */       SwingUtilities.updateComponentTreeUI(this);
/*  48 */       initColors();
/*  49 */       SwingUtilities.updateComponentTreeUI(this);
/*  50 */       setDefaultCloseOperation(3);
/*  51 */       int inset = 50;
/*  52 */       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
/*  53 */       setBounds(inset, inset, screenSize.width - inset * 2, screenSize.height - inset * 2);
/*  54 */       this.desktop = new JDesktopPane() { private Image image;
/*     */         final TopLevelGUI this$0;
/*     */ 
/*  58 */         public void paintComponent(Graphics g) { super.paintComponent(g);
/*  59 */           ImageIcon icon = new ImageIcon(TopLevelGUI.this.desktopBackgroundImage);
/*  60 */           this.image = icon.getImage();
/*  61 */           if (TopLevelGUI.this.desktopBackgroundImage == "Images/BackgroundDefault.png")
/*  62 */             g.drawImage(this.image, getWidth() - this.image.getWidth(null), getHeight() - this.image.getHeight(null), this.image.getWidth(null), this.image.getHeight(null), null);
/*     */           else
/*  64 */             g.drawImage(this.image, 0, 0, getWidth(), getHeight(), null);
/*     */         }
/*     */       };
/*  77 */       setContentPane(this.desktop);
/*  78 */       setJMenuBar(createMenuBar());
/*  79 */       loadConnectionDirectory();
/*  80 */       loadColorScheme();
/*     */ 
/*  85 */       SwingUtilities.updateComponentTreeUI(this);
/*     */     } catch (Exception e) {
/*     */     }
/*  88 */     toFront();
/*     */   }
/*     */ 
/*     */   protected void initColors()
/*     */   {
/*  93 */     this.desktopBackgroundImage = "Images/BackgroundDefault.png";
/*  94 */     buttonBackground = UIManager.getColor("Button.background");
/*  95 */     windowBackground = UIManager.getColor("Panel.background");
/*  96 */     menuBackground = UIManager.getColor("MenuBar.background");
/*  97 */     windowText = this.TEXTBLACK;
/*  98 */     menuText = this.TEXTBLACK;
/*  99 */     buttonText = this.TEXTBLACK;
/* 100 */     selectionBackground = UIManager.getColor("List.selectionBackground");
/*     */   }
/*     */ 
/*     */   protected JMenuBar createMenuBar()
/*     */   {
/* 105 */     this.menuBar = new JMenuBar();
/* 106 */     this.FileMenu = new JMenu("File");
/* 107 */     this.ConnectionDirectoryMenuItem = new JMenuItem("Connection Directory");
/* 108 */     this.NewScriptMenuItem = new JMenuItem("New Script");
/* 109 */     this.OpenEditorMenuItem = new JMenuItem("Open Editor");
/* 110 */     this.TileFramesMenuItem = new JMenuItem("Tile Frames");
/* 111 */     this.ExitMenuItem = new JMenuItem("Exit");
/* 112 */     this.ConnectionsMenu = new JMenu("Connections");
/* 113 */     this.NewSerialConnectionMenuItem = new JMenuItem("New Serial Connection");
/* 114 */     this.NewSSHConnectionMenuItem = new JMenuItem("New SSH Connection");
/* 115 */     this.RunMenu = new JMenu("Run");
/* 116 */     this.RunTestSuiteMenuItem = new JMenuItem("Run Test Suite");
/* 117 */     this.OptionsMenu = new JMenu("Options");
/* 118 */     this.WindowConfigurationMenuItem = new JMenuItem("Window Configuration");
/* 119 */     this.HelpMenu = new JMenu("Help");
/* 120 */     this.HelpMenuItem = new JMenuItem("Help");
/* 121 */     this.AboutMenuItem = new JMenuItem("About...");
/* 122 */     this.ConnectionDirectoryMenuItem.setActionCommand("12");
/* 123 */     this.ConnectionDirectoryMenuItem.addActionListener(this);
/* 124 */     this.FileMenu.add(this.ConnectionDirectoryMenuItem);
/* 125 */     this.NewScriptMenuItem.setActionCommand("1");
/* 126 */     this.NewScriptMenuItem.addActionListener(this);
/* 127 */     this.FileMenu.add(this.NewScriptMenuItem);
/* 128 */     this.OpenEditorMenuItem.setActionCommand("3");
/* 129 */     this.OpenEditorMenuItem.addActionListener(this);
/* 130 */     this.FileMenu.add(this.OpenEditorMenuItem);
/* 131 */     this.TileFramesMenuItem.setActionCommand("4");
/* 132 */     this.TileFramesMenuItem.addActionListener(this);
/* 133 */     this.FileMenu.add(this.TileFramesMenuItem);
/* 134 */     this.ExitMenuItem.setActionCommand("0");
/* 135 */     this.ExitMenuItem.addActionListener(this);
/* 136 */     this.FileMenu.add(this.ExitMenuItem);
/* 137 */     this.menuBar.add(this.FileMenu);
/* 138 */     this.NewSerialConnectionMenuItem.setActionCommand("5");
/* 139 */     this.NewSerialConnectionMenuItem.addActionListener(this);
/* 140 */     this.ConnectionsMenu.add(this.NewSerialConnectionMenuItem);
/* 141 */     this.NewSSHConnectionMenuItem.setActionCommand("6");
/* 142 */     this.NewSSHConnectionMenuItem.addActionListener(this);
/* 143 */     this.ConnectionsMenu.add(this.NewSSHConnectionMenuItem);
/* 144 */     this.menuBar.add(this.ConnectionsMenu);
/* 145 */     this.RunTestSuiteMenuItem.setActionCommand("7");
/* 146 */     this.RunTestSuiteMenuItem.addActionListener(this);
/* 147 */     this.RunMenu.add(this.RunTestSuiteMenuItem);
/* 148 */     this.menuBar.add(this.RunMenu);
/* 149 */     this.WindowConfigurationMenuItem.setActionCommand("8");
/* 150 */     this.WindowConfigurationMenuItem.addActionListener(this);
/* 151 */     this.OptionsMenu.add(this.WindowConfigurationMenuItem);
/* 152 */     this.menuBar.add(this.OptionsMenu);
/* 153 */     this.HelpMenuItem.setActionCommand("10");
/* 154 */     this.HelpMenuItem.addActionListener(this);
/* 155 */     this.HelpMenu.add(this.HelpMenuItem);
/* 156 */     this.AboutMenuItem.setActionCommand("11");
/* 157 */     this.AboutMenuItem.addActionListener(this);
/* 158 */     this.HelpMenu.add(this.AboutMenuItem);
/* 159 */     this.menuBar.add(this.HelpMenu);
/* 160 */     return this.menuBar;
/*     */   }
/*     */ 
/*     */   protected void loadConnectionDirectory()
/*     */   {
/* 165 */     File file = new File("Options/ConnectionDirectory.txt");
/* 166 */     FileReader fis = null;
/* 167 */     BufferedReader in = null;
/*     */     try
/*     */     {
/* 170 */       fis = new FileReader(file);
/* 171 */       in = new BufferedReader(fis);
/* 172 */       int counter = 0;
/* 173 */       String[] temp = new String[99];
/*     */ 
/* 176 */       while (in.ready())
/*     */       {
/* 178 */         String line = in.readLine();
/* 179 */         temp[(counter++)] = line;
/* 180 */         if (counter == 22)
/*     */         {
/* 182 */           int scriptsNumber = Integer.parseInt(in.readLine());
/* 183 */           temp[(counter++)] = ("" + scriptsNumber);
/* 184 */           for (int x = 0; x < scriptsNumber; x++) {
/* 185 */             temp[(counter + x)] = in.readLine();
/*     */           }
/* 187 */           ConnectionDirectory.put(temp[0], temp);
/* 188 */           temp = new String[99];
/* 189 */           counter = 0;
/*     */         }
/*     */       }
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 195 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void saveConnectionDirectory()
/*     */   {
/* 201 */     File file = new File("Options/ConnectionDirectory.txt");
/* 202 */     FileWriter fis = null;
/* 203 */     BufferedWriter out = null;
/*     */     try
/*     */     {
/* 206 */       fis = new FileWriter(file);
/* 207 */       out = new BufferedWriter(fis);
/* 208 */       Object[] temp = ConnectionDirectory.keySet().toArray();
/* 209 */       for (int x = 0; x < temp.length; x++)
/*     */       {
/* 211 */         String[] data = (String[])(String[])ConnectionDirectory.get(temp[x]);
/* 212 */         for (int y = 0; y < data.length; y++) {
/* 213 */           if (data[y] != null) {
/* 214 */             out.write("" + data[y] + "\n");
/*     */           }
/*     */         }
/*     */       }
/* 218 */       out.close();
/* 219 */       fis.close();
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 223 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent e)
/*     */   {
/* 229 */     Runtime runtime = Runtime.getRuntime();
/* 230 */     long maxMemory = runtime.maxMemory();
/* 231 */     long allocatedMemory = runtime.totalMemory();
/* 232 */     long freeMemory = runtime.freeMemory();
/* 233 */     if (this.totalWinNum > 10)
/* 234 */       this.totalWinNum = 0;
/*     */     try
/*     */     {
/* 237 */       switch (Integer.parseInt(e.getActionCommand()))
/*     */       {
/*     */       case 1:
/* 240 */         createNewScript();
/* 241 */         break;
/*     */       case 3:
/* 244 */         createEditorWindow();
/* 245 */         break;
/*     */       case 4:
/* 248 */         tileInternalFrames();
/* 249 */         break;
/*     */       case 5:
/* 252 */         this.portSel[(this.psCounter % 2)] = new PortSelect(this, false, this.totalWinNum);
/* 253 */         this.portSel[(this.psCounter % 2)].show();
/* 254 */         this.desktop.add(this.portSel[(this.psCounter % 2)]);
/* 255 */         this.portSel[(this.psCounter % 2)].moveToFront();
/* 256 */         this.portSel[(this.psCounter % 2)].setSelected(true);
/* 257 */         this.psCounter += 1;
/* 258 */         break;
/*     */       case 6:
/* 261 */         this.portSel[(this.psCounter % 2)] = new PortSelect(this, true, this.totalWinNum);
/* 262 */         this.portSel[(this.psCounter % 2)].show();
/* 263 */         this.desktop.add(this.portSel[(this.psCounter % 2)]);
/* 264 */         this.portSel[(this.psCounter % 2)].moveToFront();
/* 265 */         this.portSel[(this.psCounter % 2)].setSelected(true);
/* 266 */         this.psCounter += 1;
/* 267 */         break;
/*     */       case 7:
/* 270 */         createTestSuiteFrame();
/* 271 */         break;
/*     */       case 8:
/* 274 */         createOptionsFrame(0);
/* 275 */         break;
/*     */       case 10:
/* 278 */         createOptionsFrame(2);
/* 279 */         break;
/*     */       case 11:
/* 282 */         createHelpAboutFrame();
/* 283 */         break;
/*     */       case 12:
/* 286 */         createOptionsFrame(1);
/* 287 */         break;
/*     */       case 0:
/* 290 */         windowClosing(null);
/*     */       case 2:
/*     */       case 9:
/*     */       }
/*     */     }
/*     */     catch (Exception exc) {
/* 296 */       exc.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void tileInternalFrames()
/*     */   {
/* 302 */     JInternalFrame[] allframes = this.comm;
/* 303 */     int count = 0;
/* 304 */     for (int x = 0; x < allframes.length; x++) {
/* 305 */       if ((allframes[x] != null) && (!allframes[x].isClosed()))
/* 306 */         count++;
/*     */     }
/* 308 */     if (count == 0)
/* 309 */       return;
/* 310 */     int sqrt = (int)Math.sqrt(count);
/* 311 */     int rows = sqrt;
/* 312 */     int cols = sqrt;
/* 313 */     if (rows * cols < count)
/*     */     {
/* 315 */       cols++;
/* 316 */       if (rows * cols < count)
/* 317 */         rows++;
/*     */     }
/* 319 */     Dimension size = this.desktop.getSize();
/* 320 */     int w = size.width / cols;
/* 321 */     int h = size.height / rows;
/* 322 */     int x = 0;
/* 323 */     int y = 0;
/* 324 */     for (int i = 0; i < rows; i++)
/*     */     {
/* 326 */       for (int j = 0; (j < cols) && (i * cols + j < count); j++)
/*     */       {
/* 328 */         if (allframes[(i * cols + j)] == null)
/*     */           continue;
/* 330 */         JInternalFrame f = allframes[(i * cols + j)];
/* 331 */         if ((!f.isClosed()) && (f.isIcon()))
/*     */           try
/*     */           {
/* 334 */             f.setIcon(false);
/*     */           } catch (Exception ignored) {
/*     */           }
/* 337 */         this.desktop.getDesktopManager().resizeFrame(f, x, y, w, h);
/* 338 */         x += w;
/*     */       }
/*     */ 
/* 341 */       y += h;
/* 342 */       x = 0;
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createNewScript()
/*     */   {
/*     */     Process proc;
/*     */     try {
/* 351 */       File dir = new File(".");
/* 352 */       String fileDir = dir.getCanonicalPath() + "/NotepadPP/notepadPP.exe NewScript.py";
/* 353 */       Runtime rt = Runtime.getRuntime();
/* 354 */       proc = rt.exec(fileDir);
/*     */     } catch (Exception e) {
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createEditorWindow() {
/*     */     Process proc;
/*     */     try {
/* 363 */       File dir = new File(".");
/* 364 */       String fileDir = dir.getCanonicalPath() + "/NotepadPP/notepadPP.exe";
/* 365 */       Runtime rt = Runtime.getRuntime();
/* 366 */       proc = rt.exec(fileDir);
/*     */     }
/*     */     catch (Exception e) {
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createOptionsFrame(int tab) {
/* 373 */     if ((this.OGUI == null) || (this.OGUI.isClosed()))
/*     */     {
/* 375 */       this.OGUI = new OptionsGUI(this);
/* 376 */       this.OGUI.setVisible(true);
/* 377 */       this.OGUI.setSelectedTab(tab);
/* 378 */       this.desktop.add(this.OGUI);
/*     */       try
/*     */       {
/* 381 */         this.OGUI.setSelected(true);
/*     */       }
/*     */       catch (PropertyVetoException e) {
/*     */       }
/*     */     }
/*     */     else {
/*     */       try {
/* 388 */         this.OGUI.setSelected(true);
/* 389 */         this.OGUI.setSelectedTab(tab);
/* 390 */         this.OGUI.moveToFront();
/*     */       }
/*     */       catch (PropertyVetoException e)
/*     */       {
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createHelpAboutFrame() {
/*     */     try {
/* 400 */       HelpAbout HA = new HelpAbout(this);
/* 401 */       HA.setVisible(true);
/* 402 */       this.desktop.add(HA);
/* 403 */       HA.setSelected(true);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createSerialPortFrame(String portName, boolean CD) {
/*     */     try {
/* 412 */       cleanupFrames();
/* 413 */       if (CD)
/* 414 */         this.SC = new SerialPortCommunicator(((String[])(String[])ConnectionDirectory.get(portName))[1], this);
/*     */       else
/* 416 */         this.SC = new SerialPortCommunicator(portName, this);
/* 417 */       this.comm[this.commWinNum] = new Communicator(this.SC, this.commWinNum, this, false, portName, this.totalWinNum++, CD);
/* 418 */       this.comm[this.commWinNum].setVisible(true);
/* 419 */       if (!CD)
/*     */       {
/* 421 */         this.comm[this.commWinNum].setLM(new LibraryMethods(this.comm[this.commWinNum], this.SC));
/* 422 */         this.SC.setSPC(this.comm[this.commWinNum]);
/* 423 */         new Thread() {
/*     */           final TopLevelGUI this$0;
/*     */ 
/* 427 */           public void run() { TopLevelGUI.this.SC.connect();
/*     */           }
/*     */         }
/* 423 */         .start();
/*     */       }
/*     */ 
/* 440 */       this.desktop.add(this.comm[this.commWinNum]);
/* 441 */       this.comm[this.commWinNum].setSelected(true);
/* 442 */       this.commWinNum += 1;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 446 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createSSHFrame(String portName, boolean CD)
/*     */   {
/*     */     try
/*     */     {
/* 454 */       cleanupFrames();
/*     */       SSHCommunicator SSHC;
/*     */       SSHCommunicator SSHC;
/* 456 */       if (CD)
/* 457 */         SSHC = new SSHCommunicator(portName, this);
/*     */       else
/* 459 */         SSHC = new SSHCommunicator(portName, this);
/* 460 */       this.comm[this.commWinNum] = new Communicator(SSHC, this.commWinNum, this, true, portName, this.totalWinNum++, CD);
/* 461 */       this.comm[this.commWinNum].setVisible(true);
/* 462 */       this.comm[this.commWinNum].setLM(new LibraryMethods(this.comm[this.commWinNum], SSHC));
/* 463 */       SSHC.setSPC(this.comm[this.commWinNum], CD);
/* 464 */       if (CD)
/* 465 */         SSHC.getLoginInfoFromCD();
/*     */       else
/* 467 */         SSHC.getLoginInfo();
/* 468 */       this.desktop.add(this.comm[this.commWinNum]);
/* 469 */       this.comm[this.commWinNum].setSelected(true);
/* 470 */       this.commWinNum += 1;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 474 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void createTestSuiteFrame()
/*     */   {
/*     */     try
/*     */     {
/* 482 */       cleanupFrames();
/* 483 */       this.TSGUI = new TestSuiteGUI(this, this.totalWinNum++);
/* 484 */       this.TSGUI.setVisible(true);
/* 485 */       this.desktop.add(this.TSGUI);
/* 486 */       this.TSGUI.setSelected(true);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void cleanupFrames() {
/*     */     try {
/* 495 */       for (int x = 0; x < this.comm.length; x++) {
/* 496 */         if ((this.comm[x] == null) || (!this.comm[x].isClosed()))
/*     */           continue;
/* 498 */         ActiveConnectionDirectory.remove(this.comm[x].connectionName);
/* 499 */         this.comm[x] = null;
/*     */       }
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void loadColorScheme() {
/* 508 */     File file = new File("Options/UI.txt");
/* 509 */     FileReader fis = null;
/* 510 */     BufferedReader in = null;
/*     */     try
/*     */     {
/* 513 */       fis = new FileReader(file);
/* 514 */       in = new BufferedReader(fis);
/* 515 */       int counter = 0;
/* 516 */       String[] temp = new String[8];
/* 517 */       while (in.ready())
/* 518 */         temp[(counter++)] = in.readLine();
/* 519 */       if (temp[0].equals("System UI"))
/* 520 */         setSystemUI();
/*     */       else
/* 522 */         setMetalUI();
/* 523 */       windowBackground = Color.decode(temp[1]);
/* 524 */       windowText = Color.decode(temp[2]);
/* 525 */       menuBackground = Color.decode(temp[3]);
/* 526 */       menuText = Color.decode(temp[4]);
/* 527 */       buttonBackground = Color.decode(temp[5]);
/* 528 */       buttonText = Color.decode(temp[6]);
/* 529 */       selectionBackground = Color.decode(temp[7]);
/* 530 */       updateColorScheme();
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 534 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void saveColorScheme()
/*     */   {
/* 540 */     File file = new File("Options/UI.txt");
/* 541 */     FileWriter fis = null;
/* 542 */     BufferedWriter out = null;
/*     */     try
/*     */     {
/* 545 */       fis = new FileWriter(file);
/* 546 */       out = new BufferedWriter(fis);
/* 547 */       if (this.SystemLAF)
/* 548 */         out.write("System UI");
/*     */       else
/* 550 */         out.write("Metal UI");
/* 551 */       out.write("\n" + windowBackground.getRGB());
/* 552 */       out.write("\n" + windowText.getRGB());
/* 553 */       out.write("\n" + menuBackground.getRGB());
/* 554 */       out.write("\n" + menuText.getRGB());
/* 555 */       out.write("\n" + buttonBackground.getRGB());
/* 556 */       out.write("\n" + buttonText.getRGB());
/* 557 */       out.write("\n" + selectionBackground.getRGB());
/* 558 */       out.close();
/* 559 */       fis.close();
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 563 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultColorScheme()
/*     */   {
/* 569 */     buttonBackground = UIManager.getColor("Button.background");
/* 570 */     windowBackground = UIManager.getColor("Panel.background");
/* 571 */     menuBackground = UIManager.getColor("MenuBar.background");
/* 572 */     selectionBackground = UIManager.getColor("List.selectionBackground");
/* 573 */     buttonText = UIManager.getColor("Button.foreground");
/* 574 */     windowText = UIManager.getColor("Button.foreground");
/* 575 */     menuText = UIManager.getColor("MenuBar.foreground");
/* 576 */     updateColorScheme();
/*     */   }
/*     */ 
/*     */   public void updateColorScheme()
/*     */   {
/* 581 */     if (UIManager.getColor("Panel.background").equals(windowBackground))
/* 582 */       this.desktop.setBackground(UIManager.getColor("Desktop.background"));
/*     */     else
/* 584 */       this.desktop.setBackground(windowBackground);
/* 585 */     if (this.OGUI != null)
/* 586 */       this.OGUI.updateColorScheme();
/* 587 */     if (this.TSGUI != null)
/* 588 */       this.TSGUI.updateColorScheme();
/* 589 */     for (int x = 0; x < this.comm.length; x++) {
/* 590 */       if (this.comm[x] != null)
/* 591 */         this.comm[x].updateColorScheme();
/*     */     }
/* 593 */     this.menuBar.setBackground(menuBackground);
/* 594 */     this.FileMenu.setBackground(menuBackground);
/* 595 */     this.ConnectionDirectoryMenuItem.setBackground(menuBackground);
/* 596 */     this.NewScriptMenuItem.setBackground(menuBackground);
/* 597 */     this.OpenEditorMenuItem.setBackground(menuBackground);
/* 598 */     this.TileFramesMenuItem.setBackground(menuBackground);
/* 599 */     this.ExitMenuItem.setBackground(menuBackground);
/* 600 */     this.ConnectionsMenu.setBackground(menuBackground);
/* 601 */     this.NewSerialConnectionMenuItem.setBackground(menuBackground);
/* 602 */     this.NewSSHConnectionMenuItem.setBackground(menuBackground);
/* 603 */     this.RunMenu.setBackground(menuBackground);
/* 604 */     this.RunTestSuiteMenuItem.setBackground(menuBackground);
/* 605 */     this.OptionsMenu.setBackground(menuBackground);
/* 606 */     this.WindowConfigurationMenuItem.setBackground(menuBackground);
/* 607 */     this.HelpMenu.setBackground(menuBackground);
/* 608 */     this.HelpMenuItem.setBackground(menuBackground);
/* 609 */     this.AboutMenuItem.setBackground(menuBackground);
/* 610 */     this.menuBar.setForeground(menuText);
/* 611 */     this.FileMenu.setForeground(menuText);
/* 612 */     this.ConnectionDirectoryMenuItem.setForeground(menuText);
/* 613 */     this.NewScriptMenuItem.setForeground(menuText);
/* 614 */     this.OpenEditorMenuItem.setForeground(menuText);
/* 615 */     this.TileFramesMenuItem.setForeground(menuText);
/* 616 */     this.ExitMenuItem.setForeground(menuText);
/* 617 */     this.ConnectionsMenu.setForeground(menuText);
/* 618 */     this.NewSerialConnectionMenuItem.setForeground(menuText);
/* 619 */     this.NewSSHConnectionMenuItem.setForeground(menuText);
/* 620 */     this.RunMenu.setForeground(menuText);
/* 621 */     this.RunTestSuiteMenuItem.setForeground(menuText);
/* 622 */     this.OptionsMenu.setForeground(menuText);
/* 623 */     this.WindowConfigurationMenuItem.setForeground(menuText);
/* 624 */     this.HelpMenu.setForeground(menuText);
/* 625 */     this.HelpMenuItem.setForeground(menuText);
/* 626 */     this.AboutMenuItem.setForeground(menuText);
/* 627 */     this.desktop.updateUI();
/*     */   }
/*     */ 
/*     */   public void setRedColorScheme()
/*     */   {
/* 632 */     buttonBackground = this.REDBUTTONBACKGROUND;
/* 633 */     windowBackground = this.REDWINDOWBACKGROUND;
/* 634 */     menuBackground = this.REDMENUBACKGROUND;
/* 635 */     selectionBackground = this.REDSELECTIONBACKGROUND;
/* 636 */     buttonText = this.TEXTRED;
/* 637 */     windowText = this.TEXTWHITE;
/* 638 */     menuText = this.TEXTRED;
/* 639 */     updateColorScheme();
/*     */   }
/*     */ 
/*     */   public void setGreenColorScheme()
/*     */   {
/* 644 */     buttonBackground = this.GREENBUTTONBACKGROUND;
/* 645 */     windowBackground = this.GREENWINDOWBACKGROUND;
/* 646 */     menuBackground = this.GREENMENUBACKGROUND;
/* 647 */     selectionBackground = this.GREENSELECTIONBACKGROUND;
/* 648 */     buttonText = this.TEXTGREEN;
/* 649 */     windowText = this.TEXTWHITE;
/* 650 */     menuText = this.TEXTGREEN;
/* 651 */     updateColorScheme();
/*     */   }
/*     */ 
/*     */   public void setBlueColorScheme()
/*     */   {
/* 656 */     buttonBackground = this.BLUEBUTTONBACKGROUND;
/* 657 */     windowBackground = this.BLUEWINDOWBACKGROUND;
/* 658 */     menuBackground = this.BLUEMENUBACKGROUND;
/* 659 */     selectionBackground = this.BLUESELECTIONBACKGROUND;
/* 660 */     buttonText = this.TEXTBLUE;
/* 661 */     windowText = this.TEXTWHITE;
/* 662 */     menuText = this.TEXTBLUE;
/* 663 */     updateColorScheme();
/*     */   }
/*     */ 
/*     */   public void setSystemUI()
/*     */   {
/*     */     try
/*     */     {
/* 670 */       this.SystemLAF = true;
/* 671 */       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
/* 672 */       TopLevelGUI _tmp = this;
/* 673 */       setDefaultLookAndFeelDecorated(true);
/* 674 */       this.desktop.updateUI();
/* 675 */       SwingUtilities.updateComponentTreeUI(this);
/* 676 */       updateColorScheme();
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setMetalUI()
/*     */   {
/*     */     try
/*     */     {
/* 689 */       SwingUtilities.updateComponentTreeUI(this);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   public void restartSerialPort(int commWinNum) {
/*     */     try {
/* 698 */       this.SC = new SerialPortCommunicator(this.comm[commWinNum].portName, this);
/* 699 */       this.SC.setSPC(this.comm[commWinNum]);
/* 700 */       new Thread() {
/*     */         final TopLevelGUI this$0;
/*     */ 
/* 704 */         public void run() { TopLevelGUI.this.SC.connect();
/*     */         }
/*     */       }
/* 700 */       .start();
/*     */ 
/* 716 */       this.comm[commWinNum].SC = this.SC;
/* 717 */       this.comm[commWinNum].LM = new LibraryMethods(this.comm[commWinNum], this.SC);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateConnectionDirectory() {
/*     */     try {
/* 726 */       for (int x = 0; x < this.comm.length; x++) {
/* 727 */         if ((this.comm[x] != null) && (!this.comm[x].isClosed()))
/* 728 */           this.comm[x].updateConnectionDirectory();
/*     */       }
/* 730 */       for (int x = 0; x < this.portSel.length; x++)
/* 731 */         if ((this.portSel[x] != null) && (!this.portSel[x].isClosed()))
/* 732 */           this.portSel[x].updateConnectionDirectory();
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   public void windowClosing(WindowEvent e) {
/* 740 */     saveConnectionDirectory();
/* 741 */     saveColorScheme();
/* 742 */     for (int x = 0; x < this.comm.length; x++) {
/* 743 */       if (this.comm[x] != null)
/* 744 */         this.comm[x].ExitEvent();
/*     */     }
/* 746 */     System.exit(0);
/*     */   }
/*     */ 
/*     */   public void windowClosed(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowOpened(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowIconified(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowDeiconified(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowActivated(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowDeactivated(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowGainedFocus(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowLostFocus(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void windowStateChanged(WindowEvent windowevent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void createAndShowGUI()
/*     */   {
/* 787 */     HazellSplashScreen.show();
/* 788 */     TopLevelGUI frame = new TopLevelGUI();
/* 789 */     frame.setDefaultCloseOperation(3);
/* 790 */     frame.setIconImage(this.titleBarIcon.getImage());
/* 791 */     addWindowListener(this);
/* 792 */     frame.addWindowListener(this);
/* 793 */     frame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public static void main(String[] args)
/*     */   {
/* 798 */     SwingUtilities.invokeLater(new Runnable()
/*     */     {
/*     */       public void run()
/*     */       {
/* 802 */         new TopLevelGUI().createAndShowGUI();
/*     */       }
/*     */     });
/*     */   }
/*     */ }

/* Location:           F:\6-30-2012\Hazell\
 * Qualified Name:     hmc.TopLevelGUI
 * JD-Core Version:    0.6.0
 */